package com.zyy.admin.entity;

import com.zyy.api.constant.LabelType;
import com.zyy.api.converter.LabelRuleConverter;
import com.zyy.api.converter.LabelTypeConverter;
import com.zyy.api.pojo.LabelRule;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EntityListeners(AuditingEntityListener.class)
@Entity
@Table(name = "label_rule_template")
public class LabelRuleTemplate
    implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id @Column(name = "id", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id;

    /**
     * 用户ID
     */
    @Column(name = "user_id") private Integer userId;

    /**
     * 标签模板名称
     */
    @Column(name = "name") private String name;

    /**
     * 是否可用，0不可用，1可用
     */
    @Column(name = "available") private Integer available;

    /**
     * 模板详细描述信息
     */
    @Column(name = "description") private String description;

    /**
     * 模板关联的标签类型，1：主题，2：个股，3：指数，4：基金，5：债券，6：行业
     */
    @Convert(converter = LabelTypeConverter.class)
    @Column(name = "label_type") private List<LabelType> labelType;

    /**
     * 详细的规则逻辑
     */
    @Convert(converter = LabelRuleConverter.class)
    @Column(name = "rule") private List<LabelRule> rule;

    @Column(name = "created_time") private Date createdTime;

    @Column(name = "updated_time") private Date updatedTime;

}
